//
//  KYZXLeftMeunVC.m
//  KuYouZiXun
//
//  Created by lanou on 15/8/4.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "KYZXLeftMeunVC.h"

#import "KYZXScreen.h"

#import "UIImage+BlurGlass.h"

#import "KYZXUserInfo.h"
@interface KYZXLeftMeunVC ()
@property (strong, nonatomic) IBOutlet UIButton *login;

@property (weak, nonatomic) IBOutlet UISwitch *changeColorSwitch;

@property (weak, nonatomic) IBOutlet UISwitch *changeImagePlaySwitch;

@end

@implementation KYZXLeftMeunVC

- (void)dealloc
{
    [[KYZXUserInfo standardKYZXUserInfo]removeObserver:self];
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    [self getUserDefault];
    [[KYZXUserInfo standardKYZXUserInfo] addObserver:self];
}

- (void)getUserDefault{

    NSString *userColorInfo = [[NSUserDefaults standardUserDefaults] objectForKey:@"配色方案"];
    if([userColorInfo isEqualToString:@"日间模式"] || userColorInfo == nil){
        _changeColorSwitch.on = NO;
    }
    else{
        _changeColorSwitch.on = YES;
    }
    NSString *userImagePlayInfo = [[NSUserDefaults standardUserDefaults] objectForKey:@"图片方案"];
    if([userImagePlayInfo isEqualToString:@"有图模式"] || userImagePlayInfo == nil){
        _changeImagePlaySwitch.on = NO;
    }
    else{
        _changeImagePlaySwitch.on = YES;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
  

}


- (IBAction)login:(id)sender {
    
    NSLog(@"登陆");
}


//夜间模式通知
- (IBAction)changeColor:(UISwitch *)sender {
    
    if (sender.on) {
        [[NSUserDefaults standardUserDefaults] setObject:@"夜间模式" forKey:@"配色方案"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"changeColor" object:nil userInfo:@{@"配色方案":@"夜间模式"}];
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"日间模式" forKey:@"配色方案"];
        [[NSUserDefaults standardUserDefaults] synchronize];
     [[NSNotificationCenter defaultCenter] postNotificationName:@"changeColor" object:nil userInfo:@{@"配色方案":@"日间模式"}];
    }
}

//无图模式通知
- (IBAction)changeImagePlay:(UISwitch *)sender {
    
    if (sender.on) {
          [[NSUserDefaults standardUserDefaults] setObject:@"无图模式" forKey:@"图片方案"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"changeImagePlay" object:nil userInfo:@{@"图片方案":@"无图模式"}];
        
    }
    else{
        [[NSUserDefaults standardUserDefaults] setObject:@"有图模式" forKey:@"图片方案"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"changeImagePlay" object:nil userInfo:@{@"图片方案":@"有图模式"}];
    }
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    [self getUserDefault];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
